package com.diabetes.mapper;

import com.diabetes.entity.SugarRecord;
import com.diabetes.entity.User;
import com.diabetes.vo.getBloodVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    //根据ID查询
    @Select("select * from user where username = #{username}")
    User getByUsername(String username);
    //用户注册
    @Insert("insert into user (username,password) values (#{username},#{password})")
    void insertAccount(String username, String password);
    //修改个人信息
    void update(User user);

    /**
     * 储存用户血糖值
     * @param sugarRecord
     */
    @Insert("insert into sugar_record(user_id, record_date, blood_sugar, state) values " +
            "(#{userId},#{recordDate},#{bloodSugar},#{state})")
    void search(SugarRecord sugarRecord);

    @Select("select * from sugar_record where state = #{ids} ORDER BY record_date desc limit 1")
    SugarRecord getblood(Integer ids);
}
